#include "CStateLogo.h"
#include "CStateManagement.h"
#include "CStatePlay.h"
#include <stdio.h>

CStateLogo::CStateLogo():m_iCount(0), CState()
{}

void CStateLogo::Init()
{
	printf("State Logo: Init\n");
	m_iCount = 0;
}

void CStateLogo::Update()
{
	m_iCount++;
	if (m_iCount >= 10)
	{
		CStateManagement::GetInstance()->SwitchState(new CStatePlay());
	}
}

void CStateLogo::Render()
{
	printf("State Logo: %d\n", m_iCount);
}

void CStateLogo::Exit()
{
	printf("State Logo: Exit\n");
}

void CStateLogo::LoadResources(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 backBuffer)
{
	HRESULT res = D3DXCreateSprite(d3ddv, &_spriteHandler);
	//TODO: Load resource game	
	ResourceMng *rm = ResourceMng::GetInst(d3ddv, backBuffer);

	//_mario = new Mario(d3ddv, backBuffer, _spriteHandler, 200, 500, MS_NORMAL);
}

void CStateLogo::Render(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 backBuffer, int Delta)
{
	ResourceMng::GetInst(d3ddv, backBuffer)->GetSurface(L"..\\Resources\\Images\\background.jpg")->Draw(NULL, NULL ); //chu y ham Draw co 2 tham so NULL

	_spriteHandler->Begin(D3DXSPRITE_ALPHABLEND);
	_mario->render(camera->getCamera().left, camera->getCamera().top);
	_spriteHandler->End();
}

void CStateLogo::update(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer, int Delta)
{
	m_iCount++;
	if (m_iCount >= 50)
	{
		CStateManagement::GetInstance()->SwitchState(new CStatePlay());
	}
}